import { nextTick } from "vue";
import router from "@/router/index";
import { store } from "@/store/index";

/**
 * 设置浏览器标题国际化
 */
export function useTitle() {
  return () => {
    nextTick(() => {
      let webTitle = "";
      const globalTitle = store.state.themeConfig.themeConfig.globalTitle;
      webTitle = router.currentRoute.value.meta.title;
      document.title = `${webTitle} - ${globalTitle}` || globalTitle;
    });
  };
}
